// models/achievement.js

export default {
	namespace: "achievement",
	state: {
		achievements: [
			{ id: 1, name: "方田", isCompleted: false },
			{ id: 2, name: "勾股", isCompleted: false },
			{ id: 3, name: "衰分", isCompleted: false },
			{ id: 4, name: "少广", isCompleted: false },
			{ id: 5, name: "粟米", isCompleted: false },
			{ id: 6, name: "盈不足", isCompleted: false },
			{ id: 7, name: "商功", isCompleted: false },
			{ id: 8, name: "均输", isCompleted: false },
			{ id: 9, name: "方程", isCompleted: false },
		],
	},
	reducers: {
		completeAchievement(state, action) {
			return {
				...state,
				achievements: state.achievements.map(achievement =>
					achievement.id == action.payload
						? { ...achievement, isCompleted: true }
						: achievement
				),
			};
		},
	},
};
